<template>
  <div>
    <el-card>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="标名" prop="name" >
              <el-input v-model="obj01.bidName" disabled></el-input>
            </el-form-item>
            <el-form-item label="标签" prop="name" >
              <el-input v-model="obj01.tag" ></el-input>
            </el-form-item>

        <el-form-item label="标的类型" prop="region">
          <el-select v-model="obj01.bidType" placeholder="请选择活动区域">
            <el-option :label="车贷宝" value="0"></el-option>
            <el-option :label="房贷宝" value="1"></el-option>
            <el-option :label="供应链金融" value="2"></el-option>
          </el-select>
        </el-form-item>

            <el-form-item label="递增金额" prop="region">
              <el-select v-model="obj01.incrAmount" placeholder="请选择活动区域">
                <el-option label="500" value="500"></el-option>
                <el-option label="1000" value="1000"></el-option>
                <el-option label="1500" value="1500"></el-option>
              </el-select>
            </el-form-item>


            <el-form-item label="募集金额" prop="name" style="width: 50%">
              <el-input v-model="obj01.raiseAmount" ></el-input>
            </el-form-item>
            <el-form-item label="最低起投金额" prop="name" style="width: 50%">
              <el-input v-model="obj01.minAmount" ></el-input>
            </el-form-item>


            <el-form-item label="最大可投金额" prop="name" style="width: 50%">
              <el-input v-model="obj01.maxAmount" ></el-input>
            </el-form-item>

        <el-form-item label="计息的方式" prop="resource">
<!--          0：成交日 1：T+1 2: T+2 3: 成立计息-->
          <el-radio-group v-model="obj01.interestMode">
            <el-radio :label="0" >成交日</el-radio>
            <el-radio :label="1" >T+1 </el-radio>
            <el-radio :label="2" >T+2</el-radio>
            <el-radio :label="3" >成立计息</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="募集类型" prop="region">
          <el-select v-model="obj01.raiseType" placeholder="请选择活动区域">
            <el-option label="天" value="0"></el-option>
            <el-option label="小时" value="1"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="募集时长(天/小时)" prop="desc">
          <el-input type="textarea" v-model="obj01.raiseNum"></el-input>
        </el-form-item>
        <el-form-item label="项目介绍" prop="desc">
          <el-input type="textarea" v-model="obj01.proDesc"></el-input>
        </el-form-item>
        <el-form-item label="风控措施" prop="desc">
          <el-input type="textarea" v-model="obj01.rcms"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="toBack()">返回标的上架</el-button>
          <el-button type="primary" @click="updateDetail()">确认修改</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    {{obj01}}
  </div>

</template>

<script>
  export default {
    name: 'addbiao',
    data(){
      return{
        obj01:{},
        id:null,//借款信息的id
        obj:{},//借款信息对象
        ruleForm: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        rules: {
          // name: [
          //   { required: true, message: '请输入活动名称', trigger: 'blur' },
          //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          // ],
          // region: [
          //   { required: true, message: '请选择活动区域', trigger: 'change' }
          // ],
          // date1: [
          //   { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          // ],
          // date2: [
          //   { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
          // ],
          // type: [
          //   { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
          // ],
          // resource: [
          //   { required: true, message: '请选择活动资源', trigger: 'change' }
          // ],
          // desc: [
          //   { required: true, message: '请填写活动形式', trigger: 'blur' }
          // ]
        }
      };
    },
    methods:{
      updateDetail:function(){
        this.$http.post("/finance-service-borrowing/ebankbidinfo/updateDetail",this.obj01).then((res)=>{
          if (res.data.success){
            this.$message({
              message:"修改成功!",
              type:"success"
            })
            this.$router.push('/biaoup');
            this.obj01 = {}
          }else {
            alert("添加失败!");
          }
          }
        )
      },
      toBack:function(){
        this.$router.push('/biaoup');
        this.obj01 = {};
      },
      toadd:function(){//添加
        this.$http.post("/finance-service-borrowing/ebankbidinfo/toadd",this.obj01).then(res=>{
          if(res.data.success){
            this.$router.push("/biaoup")
          }
        })
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');

            this.toadd();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      searchDetail:function () {
        this.$http.post("/finance-service-borrowing/ebankbidinfo/toLookById/"+this.id).then((res)=>{
          if (res.data.success){
            this.obj01 = res.data.result;
            this.$message({
              message:"查询成功",
              type:"success"
            })
          }else {
            alert("查询失败！")
          }
          }
        )
      }
    },
    mounted () {
      this.id = this.$route.query.id;//标的id
      this.searchDetail();
    }
  }
</script>

<style scoped>

</style>
